Reverse a linked list from position m to n. Do it in one-pass.
Note: 1 ≤ m ≤ n ≤ length of list.
Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5->NULL
# Definition for singly-linked list.# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclassSolution: defreverseBetween(self, head: ListNode, m: int, n: int) ->ListNode: dummy=ListNode(next=head) start=curr=dummynext=curr.nextfor_inrange(m-1): start=curr=nextnext=curr.nextfor_inrange(n-m+1): prev=currcurr=nextnext=curr.nextcurr.next=prevstart.next.next=nextstart.next=currreturndummy.next